package com.tm.utils;



import com.alibaba.fastjson.JSON;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wangSang
 * @create 2022-09-04 21:52
 */
public class ResponseUtil {

    public static void outputJSON(HttpServletResponse response, Object object){
        try {
            response.setContentType("application/json;charset=utf-8");
            response.setCharacterEncoding("utf-8");
            ServletOutputStream outputStream = null;
            outputStream = response.getOutputStream();
            outputStream.write(JSON.toJSONString(object).getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
